#include<bits/stdc++.h>
using namespace std;
namespace IO{
    const int BUF=1<<21;
    char buff[BUF],*p1=buff,*p2=buff;
    #define gc() (p1==p2&&(p2=((p1=buff)+fread(buff,1,BUF,stdin)),p1==p2)?EOF:*p1++)
    template<typename T>inline void read(T &x){
        char ch=gc();x=0;int f=1;
        while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
        while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=gc();
        x*=f;
    }
    char obuf[BUF],*p3=obuf;
    inline void pc(char ch){
        if(p3-obuf<BUF) *p3++=ch;
        else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
    }
    inline void put(const char *s){while(*s) pc(*s),++s;}
    char ch[32],ctop;
    template<typename T>inline void print(T x){
    	if(x<0) x=~x+1,pc('-');
        if(!x) return pc(48);
        while(x) ch[++ctop]=x%10^48,x/=10;
        while(ctop) pc(ch[ctop--]);
    }
    inline void flush(){fwrite(obuf,p3-obuf,1,stdout);p3=obuf;}
}
using namespace IO;
const int N=3e5+5,mod=998244353;
int n,k,q,x[N],y[N],a[N],t[N];
inline void add(int x){for(;x;x-=x&-x) ++t[x];}
inline int query(int x){
	int ans=0;
	for(;x<=n;x+=x&-x) ans+=t[x];
	return ans;
}
inline long long get(){
	for(int i=1;i<=n;++i) t[i]=0;
	long long ans=0;
	for(int i=1;i<=n;++i){
		ans+=query(a[i]);
		add(a[i]); 
	}return ans;
}
int sum,cnt;
void dfs(int i){
	if(i==k+1){
		sum+=get();
		++cnt;
		return;
	}
	for(int x=1;x<n;++x)
	for(int y=x+1;y<=n;++y){
		swap(a[x],a[y]);
		dfs(i+1);
		swap(a[x],a[y]); 
	}
}
inline int Inv(int x){
	int ans=1;
	for(int y=mod-2;y;y>>=1,x=1ll*x*x%mod)
		if(y&1) ans=1ll*ans*x%mod;
	return ans;
}
int main(){
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	read(n),read(k),read(q);
	for(int i=1;i<=n;++i) read(a[i]);
	for(int i=1;i<=q;++i) read(x[i]),read(y[i]);
	if(n<=4&&k<=10){
		for(int i=0;i<=q;++i){
			if(i) swap(a[x[i]],a[y[i]]);
			sum=cnt=0;
			dfs(i+1);
			cout<<1ll*sum*Inv(cnt)%mod<<'\n';
		}return 0;
	}
	if(!k) cout<<get()%mod<<'\n';
	long long ans=get()%mod,inv=Inv(1ll*n*(n-1)/2%mod);
	for(int i=1;i<=n;++i){
		int now=query(a[i]);
		ans=(ans-1ll*now*(n-i+1)%mod*inv%mod+mod)%mod;
		add(a[i]);
	}
	cout<<ans<<'\n';
	swap(a[x[1]],a[y[1]]);
	cout<<get()%mod<<'\n';
	return 0;
}


